<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 合并两个有序数组
        // 两个数组，合并，有序
        function mergedSortedArrays (nums1, m, nums2, n) {
            let i = 0;
            let j = 0;
            while (j < nums2.length) {
                if (nums1[i] > nums2[j]) {
                    let temp = nums1[i]
                    nums1[i] = nums2[j]
                    nums1[m] = nums2[j]
                    j++
                } else {
                    ans.push(nums1[i])
                    i++
                }
            }
        }

        console.log(mergedSortedArrays([1,2,3], [2,4,5]));
        
    </script>
</body>
</html>